# 智慧医疗RAG系统API测试脚本
# 使用方法: .\test-api.ps1

Write-Host "=== 智慧医疗RAG系统API测试 ===" -ForegroundColor Green

# 测试健康检查
Write-Host "`n1. 测试健康检查..." -ForegroundColor Yellow
try {
    $healthResponse = Invoke-RestMethod -Uri "http://localhost:8080/api/triage/health" -Method Get
    Write-Host "健康检查通过: $($healthResponse.status)" -ForegroundColor Green
    Write-Host "版本: $($healthResponse.version)" -ForegroundColor Green
    Write-Host "时间: $($healthResponse.timestamp)" -ForegroundColor Green
}
catch {
    Write-Host "健康检查失败: $($_.Exception.Message)" -ForegroundColor Red
    exit 1
}

# 测试文本分诊
Write-Host "`n2. 测试文本分诊..." -ForegroundColor Yellow
$triageRequest = @{
    chiefComplaint = "持续性胸痛2小时，伴冷汗"
    symptoms = @("胸痛", "冷汗", "呼吸困难")
    vitalSigns = @{
        bloodPressure = "90/60mmHg"
        heartRate = 110
        temperature = 36.8
        respiratoryRate = 24
        oxygenSaturation = 95
    }
    medicalHistory = "高血压病史5年"
    textData = "患者主诉持续性胸痛，伴有冷汗和呼吸困难，血压偏低，心率增快"
} | ConvertTo-Json -Depth 3

try {
    $triageResponse = Invoke-RestMethod -Uri "http://localhost:8080/api/triage/analyze" -Method Post -Body $triageRequest -ContentType "application/json"
    Write-Host "分诊分析成功!" -ForegroundColor Green
    Write-Host "推荐科室: $($triageResponse.recommendation.recommendedDepartment)" -ForegroundColor Green
    Write-Host "优先级: $($triageResponse.recommendation.priority)" -ForegroundColor Green
    Write-Host "置信度: $($triageResponse.confidence)" -ForegroundColor Green
    Write-Host "是否有效: $($triageResponse.isValid)" -ForegroundColor Green
    Write-Host "追溯来源数量: $($triageResponse.traceabilitySources.Count)" -ForegroundColor Green
}
catch {
    Write-Host "分诊分析失败: $($_.Exception.Message)" -ForegroundColor Red
}

# 测试简单分诊
Write-Host "`n3. 测试简单分诊..." -ForegroundColor Yellow
$simpleRequest = @{
    chiefComplaint = "头痛"
    symptoms = @("头痛", "恶心")
    vitalSigns = @{
        bloodPressure = "120/80mmHg"
        heartRate = 80
        temperature = 37.0
        respiratoryRate = 16
        oxygenSaturation = 98
    }
    textData = "患者主诉头痛，伴有恶心症状"
} | ConvertTo-Json -Depth 3

try {
    $simpleResponse = Invoke-RestMethod -Uri "http://localhost:8080/api/triage/analyze" -Method Post -Body $simpleRequest -ContentType "application/json"
    Write-Host "简单分诊分析成功!" -ForegroundColor Green
    Write-Host "推荐科室: $($simpleResponse.recommendation.recommendedDepartment)" -ForegroundColor Green
    Write-Host "优先级: $($simpleResponse.recommendation.priority)" -ForegroundColor Green
    Write-Host "置信度: $($simpleResponse.confidence)" -ForegroundColor Green
}
catch {
    Write-Host "简单分诊分析失败: $($_.Exception.Message)" -ForegroundColor Red
}

Write-Host "`n=== 测试完成 ===" -ForegroundColor Green 